#!/usr/bin/env python
# coding: utf-8

# # 元组（tuple)
# * 它和list几乎完全一样的序列数据
# * 与list不用的是 不可变（因为不可变，所以几乎没有方法）
# * 元组的形式：（1，2，3，4，5） 对比 元组（） 列表[]

# In[2]:


stu_id = "10001","10002","10003","10001"
print(stu_id,type(stu_id))


# In[3]:


stu_id.count("10001")


# In[5]:


stu_id.index("10001")


# In[8]:


import time
time.localtime()


# # 字典
# * 创建字典的三种常见方法
#   * 直接按照字典的格式创建：{key1：value1，key2：value2，.....}
#   * dict()函数来创建字典：dict(key1=value1,key2=value2, ......)
#   * 字典数据增加的方式：新建空字典 dict_name ={} ，dict_name[key1]=value1 ...
# * 字典的性质

# In[2]:


# 1.直接按照字典的格式创建：{key1：value1，key2：value2，.....}
stud_info = {
    "stud_10001":"Alex",
    "stud_10002":"Cathy",
    "stud_10003":"Adeam"
}
stud_info


# In[8]:


# 2.dict()函数来创建字典：dict(key1=value1,key2=value2, ......)
stud_info_02 = dict(
    stud_10001 = "Alex",
    stud_10002 = "Alx",
    stud_10003 = "Aex",)
stud_info_02    


# In[10]:


stud_info_03 = {}
stud_info_03["stud_10001"] = "Alex"
stud_info_03["stud_10002"] = "lex"
stud_info_03["stud_10003"] = "Aex"
stud_info_03


# In[1]:


xiaoming = {"name":"xiaoming",
           "age": 20,
           "height": 1.8}
print(xiaoming)


# In[4]:


xiaoming = {"name":"xiaoming",
           "age": 20,
           "height": 1.8}
# 1.取值 [""]
#在取值时，如果key不存在，程序会报错
# print(xiaoming["name12"])
print(xiaoming["name"])
# 2.增加或修改
# 如果key不存在，会新增加键值对
xiaoming["hobby"]="唱歌"
print("增加",xiaoming)
# 如果key存在，则修改键值对
xiaoming["age"]=30
print("修改",xiaoming)
# 3.删除 pop/del
xiaoming.pop("height")
print("删掉体重",xiaoming)
del xiaoming["name"]
print("删掉名字",xiaoming)
# 3.1随机删除
xiaoming.popitem()
print("随机删除",xiaoming)
# 4.统计键值对数量 len
print(len(xiaoming))
# 5.合并字典 update
# 注意：如果被合并的字典包括原来的键值对时，原来的键值对值会被覆盖
xh = {"score" :99,
     "name": "xiaohong"}
xiaoming.update(xh)
print("合并",xiaoming)
# 6.清空字典
xiaoming.clear()
print("清空",xiaoming)


# In[20]:


xm = {"name":"Cathy",
     "qq":"545",
     "phone":"1565464645"}
# 迭代遍历字典
# 变量i是每一次循环中获取到的键值对key
for i in xm:
    print("%s - %s"% (i,xm[i]))


# In[8]:



vowels = ["a","e","i","o","u"]
word = input("Provide a word to search for vowels:")
found = {}

# found["a"]=0
# found["e"]=0
# found["i"]=0
# found["u"]=0
found = found.fromkeys(vowels,0)

for letter in word:
     if letter in vowels:
         found[letter] += 1
 
 # print(found.items())
for k,v in found.items():
    print(k,"was found",v,"time(s)")# print(found)


# ## 特性
# * dict是无序的
# * key是唯一的
# * key是

# In[ ]:




